using RayDen.Library.Core.Noise;
using RayDen.Library.Core.Primitives;
using RayDen.Library.Entity.Scene;
using RayDen.RayEngine.Core.Types;

namespace RayDen.RayEngine.Samplers
{
    public class VolumeMaterialSampler
    {
        public void Sample(VolumeMaterialInfo info, float distance, ref RayData ray, out VolumeHitData vhd)
        {
            var pt = ray.Point(distance);
            var n3d = //NoiseProvider.Instance.Noise(pt.x, pt.y, pt.z);
                        NoiseProvider.Instance.Turbulence(pt.x, pt.y, pt.z, 6);
            var t3d = NoiseProvider.Instance.Turbulence(pt.x, pt.y, pt.z, 4);
            // Sample texture   info.Density
            vhd = new VolumeHitData()
            {
                IoR = info.MediumInfo.IoR,
                Emittance = info.Outscattering*t3d,
                Absorbance = info.Absorbtion*n3d,
                Scattering = ((info.Inscattering + info.Absorbtion) * t3d) / info.Inscattering,
                Density = 0.05f//NoiseProvider.Instance.Noise(pt.x,pt.y,pt.z),                
            };

        }
        
    }
}